﻿@{
    ViewBag.Title = "XGroup";
    Layout = "~/Views/Shared/Houyun.cshtml";
}


<div class="page-header clearfix">
    <h1 class="pull-left">小组管理</h1>
    <div class="pull-right">

        <a class="btn btn-success btn-sm"
           href="/Group/GroupCreate"
           target="blank">创建小组</a>


    </div>
</div>

<ul class="nav nav-tabs mbm">
    <li class="active">
        <a href="/Group/xiaogroup">小组管理</a>

    </li>
    <li>
        <a href="/Group/Threads">话题管理</a>

    </li>
</ul>

<form id="message-search-form" class="form-inline well well-sm" action="/Group/Xgroup" method="get">

    <div class="form-group">

        <select class="form-control" name="GSTATE">
            <option value="">小组状态</option>
            <option value="1">开启</option>
            <option value="0">关闭</option>
        </select>
    </div>
    
    <div class="form-group">
        <input class="form-control" type="text" placeholder="小组名" name="GNAME" value="">
    </div>

    <div class="form-group">
        <input class="form-control" type="text" placeholder="组长" name="Uname" value="">
    </div>

    <button class="btn btn-primary">搜索</button>

</form>
<table class="table table-striped table-hover" id="group-table">
    <thead>
        <tr>
            <th>编号</th>
            <th width="20%">名称</th>
            <th>组长</th>
            <th>成员数</th>
            <th>话题数</th>
            <th>回复数</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in ViewBag.group as List<LeEdu.MODEL.Group>)
        {


            <tr>
                <td>@item.GroupID</td>
                <td>
                    <strong>
                        <a target="_blank" href="/Group/GroupHomepage/@item.GroupID">@item.GNAME</a>
                    </strong>
                    @if (item.GSTATE == 0)
                    {
                        <label class="label label-danger">关闭</label>
                    }

                </td>

                <td>
                    <a target="_blank" href="/my/Index">

                        @item.UserAndGroup.Where(t => Convert.ToInt32(t.GPOSITION) == 0 && t.GroupID == item.GroupID).FirstOrDefault().Users.Uname
                    </a>
                </td>

                <td>
                    @item.UserAndGroup.Count()
                </td>

                <td>
                    @item.Topicshi.Count()
                </td>

                <td>
                    @(item.Topicshi.Count() == 0 ? 0 : item.Topicshi.FirstOrDefault(t => t.GroupID == item.GroupID).Reply.Count())
                </td>

                <td>
                    @(item.GSTATE == 0 ? "关闭" : "开启")
                </td>

                <td>

                    <div class="btn-group">

                        <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                            编辑
                            <span class="caret"></span>
                        </button>

                        <ul class="dropdown-menu">
                            <li><a href="#" target="_blank"><span class="glyphicon glyphicon-eye-open"></span> 查看小组</a></li>

                            @if (item.GSTATE == 0)
                            {
                                <li><a href="/Group/EditGroupState/@item.GroupID" class="close-group" onclick="return confirm('确定要开启小组')" data-url="#"><span class="glyphicon glyphicon-ok"></span> 开启小组</a></li>
                            }
                            else
                            {
                                <li><a href="/Group/EditGroupState/@item.GroupID" class="close-group" onclick="return confirm('确定要关闭小组')" data-url="#"><span class="glyphicon glyphicon-remove"></span> 关闭小组</a></li>
                            }

                            <li><a href="/Group/EditGroupUser/@item.GroupID" class="transfer-group" data-target="#GroupEditUser" data-toggle="modal"><span class="glyphicon glyphicon-refresh"></span> 转移小组</a></li>

                        </ul>
                    </div>
                </td>
            </tr>
        }





    </tbody>

</table>

<div>
    <div style="float:left">
        <a href="/Group/XGroup/?pageIndex=1&GSTATE=@(ViewBag.GSTATE)&GNAME=@(ViewBag.GNAME)&Uname=@(ViewBag.Uname)" class="btn btn-default">首页</a>
        <a href="/Group/XGroup/?pageIndex=@((ViewBag.pageIndex-1)>1?(ViewBag.pageIndex-1):1)&GSTATE=@(ViewBag.GSTATE)&GNAME=@(ViewBag.GNAME)&Uname=@(ViewBag.Uname)" class="btn btn-default">上一页</a>&nbsp;
        <span class="btn btn-circle-xs btn-danger ">@ViewBag.pageIndex/@ViewBag.pageCount</span>&nbsp;
        <a href="/Group/XGroup/?pageIndex=@((ViewBag.pageIndex+1)<ViewBag.pageCount?(ViewBag.pageIndex+1):ViewBag.pageCount)&GSTATE=@(ViewBag.GSTATE)&GNAME=@(ViewBag.GNAME)&Uname=@(ViewBag.Uname)" class="btn btn-default">下一页</a>
        <a href="/Group/XGroup/?pageIndex=@ViewBag.pageCount&GSTATE=@(ViewBag.GSTATE)&GNAME=@(ViewBag.GNAME)&Uname=@(ViewBag.Uname)" class="btn btn-default">尾页</a>
    </div>
    <div style="float:right">
        <form action="/Group/Xgroup" method="post">
            <input id="Hidden1" type="hidden" name="GSTATE" value="@ViewBag.GSTATE" />
            <input id="Hidden1" type="hidden" name="GNAME" value="@ViewBag.GNAME" />
            <input id="Hidden1" type="hidden" name="Uname" value="@ViewBag.Uname" />
            <p>
                <span style="">跳转到：</span>
                <input class="inputwidth" type="text" name="pageIndex" id="pageIndex" value="" size="3">
                <input id="Submit1" type="submit" value="GO" />
            </p>
        </form>
    </div>


</div>

<div class="pull-right">

</div>
@*模态框转移小组*@

<div class="modal fade" id="GroupEditUser" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
        </div><!-- /.modal-content -->
    </div>
</div>
<script>
    $("#GroupEditUser").on("hidden.bs.modal", function () {
        $(this).removeData("bs.modal");
    })
</script>

